﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SIOCUR.Models;

namespace SIOCUR.Controllers
{
    public class ProgramaTerminalController : Controller
    {
        SIOCURRepository dbpRepository = new SIOCURRepository();
        //
        // GET: /ProgramaTerminal/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Registra()
        {
            return View("Registra");
        }

        [HttpPost]
        public ActionResult Registra(FormCollection formValues, PROGRAMA_EN_TERMINAL progTer)
        {
            String estacion = Session["sesionestacion"] as string;
            String sistema = Session["sesionsistema"] as string; 
            
            if (ModelState.IsValid)
            {
                dbpRepository.AddProgramaTerminal(estacion, sistema, Request.Form[0], Request.Form[1], DateTime.Now, Request.Form[2], Request.Form[3], Request.Form[4]);
            }
            else
            {
                return View();
            }

            return View();

        }

        public ActionResult Todos()
        {
            var condiciones = dbpRepository.FindAllProgramaTeminal().ToList();
            return View(condiciones);
        }

    }
}
